package struts2.hanh;

import java.util.ArrayList;
import DAO.Dao_Programme;
import Entity.Programme;
import com.opensymphony.xwork2.ActionSupport;

public class DetailAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String name;
	private String des;
	private String contact;
	private boolean active;

	private Programme prog;
	private ArrayList<Programme> listPro;

	public String execute() {
		
		System.out.println("name="+name);
		System.out.println("des="+des);
		System.out.println("contact="+contact);
		System.out.println("active="+active);

		Dao_Programme cont = new Dao_Programme();
		listPro = cont.getProgram();

		int sizeList = listPro.size();
		for (int i = 0; i < sizeList; i++) {

			if (listPro.get(i).getName().equals(name)) {
				setProg(new Programme(listPro.get(i).getName(), listPro.get(i)
						.getDes(), listPro.get(i).getContact(), listPro.get(i)
						.isActive()));
				name=listPro.get(i).getName();
				des=listPro.get(i).getDes();
				contact=listPro.get(i).getContact();
				active=listPro.get(i).isActive();
			}
		}
		getProg();
		return "success";
	}

	

	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}



	public String getDes() {
		return des;
	}



	public void setDes(String des) {
		this.des = des;
	}



	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public ArrayList<Programme> getListPro() {
		return listPro;
	}

	public void setListPro(ArrayList<Programme> listPro) {
		this.listPro = listPro;
	}

	public Programme getProg() {
		return prog;
	}

	public void setProg(Programme prog) {
		this.prog = prog;
	}

}
